<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@page import="validator.Validators"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/jquery.validate.js"></script>
	<script type="text/javascript" src="js/jquery.validate.additional.method.js"></script>
	<script type="text/javascript" src="js/validate.js"></script>
	<script type="text/javascript">
		$(function(){
		
			$('#form').validate({
				//<%=Validators.DEMO_ACTION_LOGIN%>//注释此行代码验证后台输入验证是否生效
			})
			
			//动态绑定后台未映射的jquery validation方法
			//$('#id').rules("add",{required: true});
			
			//后台验证后，错误消息显示
			//注意此处的html要与jquery.validate生成的html一致，才能在输入错误时返回页面后，再次输入validate能对错误消息的显示进行控制
			showErr({${ERR_MSGS}});
			
			
			//由于struts上传文件得到的文件是.tmp文件，所以需要fileName字段来保存文件名以做判断
			$('#file').change(function(){
				$('#fileName').val($('#file').val());
			})
		})
	</script>
  </head>
  
  <body>
  	<form action="demo!login.action" method="post" id="form" enctype="multipart/form-data">
  		name:<input name="name"/><br/>
  		number:<input name="number" value="xx"/><br/>
  		age:<input name="age" value="5" id='age'/><br/>
  		phone:<input name="phone" value="110" id='phone'/><br/>
  		equalTo age:<input name="age2"/><br/>
  		equalTo phone:<input name="phone2"/><br/>
  		file:<input type="file" name="file" id="file"/><input type="hidden" name="fileName" id="fileName"/> <br/>
  		date:<input name="date" value="2012-01-01"/><br/>
  		<input type="submit" value="提交">提交看看，然后开启表单验证试试
  	</form>
  </body>
</html>
